<template>
  <a-date-picker
    v-model:value="dateValue"
    :value-format="valueFormat"
    :format="valueFormat"
    :open="openDatePick"
    :get-popup-container="(trigger:any) => trigger.parentNode"
    @focus="focusPick"
    @blur="focusBlur"
    @change="changePick"
  />
</template>

<script lang="ts" setup>
import { ref } from 'vue'

withDefaults(defineProps<{
  valueFormat?: string
}>(), {
  valueFormat: 'YYYY-MM-DD'
})

let dateValue=ref('')
const emit = defineEmits(['getDateData'])
// 时间选择
const openDatePick = ref(false)
const focusPick = (): void => {
  openDatePick.value = true

}
const focusBlur = (): void => {
  openDatePick.value = false
}
const changePick = (value:any): void => {
  openDatePick.value = false
  document.querySelectorAll('input').forEach((item) => {
    item.blur()
  })
  emit('getDateData',value)
}
</script>
